package srv

import (
	"back/entity/nailEntity"
)

type NailPay struct {
	memberCard MemberCard
	service    NailService
}

func NewNailPay(
	memberCard MemberCard,
	service NailService) NailPay {
	return NailPay{memberCard, service}
}
func (p NailPay) Pay(cardId int64, rec nailEntity.NailService) error {
	err := p.service.Create(&rec)
	if err != nil {
		return err
	}
	err = p.memberCard.TopUPX(cardId, rec.Amount)
	if err != nil {
		return err
	}
	return nil
}
